#include <system.h>

void* memcpy(void* destination, const void* source, size_t num) {
  uint8_t* dest = (uint8_t*) destination;
  const uint8_t* src = (const uint8_t*) source;
  for(; num != 0; num--) *dest++ = *src++;
  return destination;
}

void* memcpyw(void* destination, const void* source, size_t num) {
  uint16_t* dest = (uint16_t*) destination;
  const uint16_t* src = (const uint16_t*) source;
  for(; num != 0; num--) *dest++ = *src++;
  return destination;
}

void* memset(void* ptr, int value, size_t num) {
  uint8_t* dest = (uint8_t*) ptr;
  for(; num != 0; num--) *dest++ = value;
  return ptr;
}

void* memsetw(void* ptr, int value, size_t num) {
  uint16_t* dest = (uint16_t*) ptr;
  for(; num != 0 ; num--) *dest++ = value;
  return ptr;
}

size_t strlen(const uint8_t* str) {
  size_t ret = 0;
  while(*str++ != 0) ret++;
  return ret;
}
